package com.echo.im.server.mq;


import com.echo.im.common.enums.IMCmdType;
import com.echo.im.common.model.IMRecvInfo;
import com.echo.im.common.vo.message.PrivateMessageVO;
import com.echo.im.mq.contant.QueueConstants;
import com.echo.im.mq.event.receiver.AbstractMessageReceiver;
import com.echo.im.server.netty.IMServerGroup;
import com.echo.im.server.netty.processor.MessageProcessor;
import com.echo.im.server.netty.processor.factory.ProcessorFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 *
 * @author echo
 * @date 2024-08-13
 */
@Component
@RequiredArgsConstructor
@Slf4j
@DependsOn("IMServerGroup")
public class PrivatePushMessageReceiver extends AbstractMessageReceiver<IMRecvInfo<PrivateMessageVO>> {

    private final ProcessorFactory processorFactory;

    @Override
    public void doReceive(IMRecvInfo<PrivateMessageVO> recvInfo) {
        MessageProcessor<IMRecvInfo<PrivateMessageVO>> processor = processorFactory.createProcessor(IMCmdType.PRIVATE_MESSAGE);
        processor.process(recvInfo);
    }

    @Override
    public String getQueueName() {
        return QueueConstants.PUSH_PRIVATE_QUEUE+"."+ IMServerGroup.serverId;
    }
}
